class Cache {
  storage;
  constructor(storage = localStorage) {
    this.storage = storage;
  }
  getCache(key) {
    const value = this.storage.getItem(key);
    if (value) {
      return JSON.parse(value);
    }
  }

  setCache(key, value) {
    this.storage.setItem(key, JSON.stringify(value));
  }
  removeCache(key) {
    this.storage.removeItem(key);
  }

  clearCache() {
    this.storage.clear();
  }
}

const cache = new Cache();
export default cache;
